package com.star.common.orm.entity;

import com.star.common.orm.enums.SortTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 排序参数
 *
 * @author zhouhengzhe
 */
@Data
public class SortParam {

    @ApiModelProperty("排序字段，格式为表字段，如xxx_xxx，非驼峰式命名")
    private String sortField;

    @ApiModelProperty("排序方式，默认正序asc")
    private String sortType;

    public static SortParam asc(String sortField) {
        return new SortParam(sortField, SortTypeEnum.ASC.getCode());
    }

    public static SortParam desc(String sortField) {
        return new SortParam(sortField, SortTypeEnum.DESC.getCode());
    }

    public SortParam() {
        this.sortType = SortTypeEnum.ASC.getCode();
    }

    public SortParam(String sortField, String sortType) {
        this.sortField = sortField;
        this.sortType = sortType;
    }

}